<template>
  <div id="AsnDetailList">
    <v-tableTitle
      :btnConfig="btnConfig"
      :tableSelectData="selectData"
      @backList="backList"
      @del="del"
      @newCreate="newCreate"
    ></v-tableTitle>

    <div class="detail">
      <v-navMenu
        :detailNav="detailNav"
        :menuData="menuData"
        @setMentActive="setMentActive"
        v-if="detailNav!=1"
      ></v-navMenu>
      <component
        :data="{detailData,argument}"
        :is="currentComponent"
      ></component>
    </div>
  </div>

</template>

<script>
import tableTitle from "commons/TableTitle";
import navMenu from "commons/NavMenu";
import baseMixin from "@/mixins/BaseMixin";

export default {
  name: "AsnDetailList",
  mixins: [baseMixin],
  data () {
    return {
      newFlag: false,
      argument: {},
      detailsFlag: false,
      detailData: {},
      selectData: [],
      menuData: [
        { label: this.$t('bill.detail'), index: "2" },
        { label: this.$t('outbound.locDetail'), index: "3" },
        { label: this.$t('outbound.goodsDetail'), index: "4" },
        { label: this.$t('outbound.locState'), index: "5" },
        { label: this.$t('config.batchProp'), index: "6" }
      ],
      detailNav: "1",
      componentConfig: [
        {
          name: "Table",
          label: this.$t('config.tableDetail'),
          component: () => import('./page/Table.vue')
        },
        {
          name: "Detail",
          label: this.$t('bill.detail'),
          component: () => import('./page/Detail.vue')
        },
        {
          name: "Loc",
          label: this.$t('outbound.locDetail'),
          component: () => import('./page/Loc.vue')
        },
        {
          name: "Goods",
          label: this.$t('outbound.goodsDetail'),
          component: () => import('./page/Goods.vue')
        },
        {
          name: "State",
          label: this.$t('outbound.locState'),
          component: () => import('./page/State.vue')
        },
        {
          name: "Batch",
          label: this.$t('config.batchProp'),
          component: () => import('./page/Batch.vue')
        }
      ],
    }
  },
  computed: {
    btnConfig () {
      if (this.newFlag && this.detailNav == "2") {
        return []
      } else if (this.detailNav == "1") {
        return [
          { label: this.$t('common.create'), certigier: !this.btnPermNameList.includes('WM03070105'),invalid: "newCreate" },
          { label: this.$t('common.delete'), certigier: !this.btnPermNameList.includes('WM03070106'),disabled: true, invalid: "del" },
        ]
      } else if (this.detailNav == "2") {
        return [
          { label: this.$t('outbound.backList'),certigier: !this.btnPermNameList.includes('WM03070107'), invalid: "backList" },
        ]
      }
      return []
    },
    currentComponent () {
      return this.componentConfig[this.detailNav - 1].component;
    }
  },
  methods: {
    //删除数据
    async del (data) {
      try {
        let res = await this.$api.post(`deleteputawaystrategydetail`, data);
        
          this.$message.success(res.returnMgr);
          this.$children[1].getTableData()
          this.$children[1].$refs.table.delSelectData(data);
        
      } catch (e) {
        this.$message.error(e);
      }
    },

    //返回试图
    backList () {
      this.detailsFlag = false;
      this.detailNav = '1';
    },
    //新建
    async newCreate () {
      this.detailData = {
        stepnumber: '10',
        allowfullcases: "Y",
        allowfullpallets: "Y",
        allowpieces: "Y",
        areakey: " ",
        areatypeexclude01: " ",
        areatypeexclude02: " ",
        areatypeexclude03: " ",
        checkequipmentprofilekey: "N",
        checkrestrictions: "Y",
        dimensionrestriction01: "0",
        dimensionrestriction02: "0",
        dimensionrestriction03: "0",
        dimensionrestriction04: "0",
        dimensionrestriction05: "0",
        dimensionrestriction06: "0",
        dispositiontypeexclude01: " ",
        dispositiontypeexclude02: " ",
        dispositiontypeexclude03: " ",
        dispositiontypeinclude01: " ",
        dispositiontypeinclude02: " ",
        dispositiontypeinclude03: " ",
        fitfullreceipt: "N",
        fromloc: "",
        locabcexclude01: " ",
        locabcexclude02: " ",
        locabcexclude03: " ",
        locabcinclude01: " ",
        locabcinclude02: " ",
        locabcinclude03: " ",
        locationcategoryexclude01: " ",
        locationcategoryexclude02: " ",
        locationcategoryexclude03: " ",
        locationcategoryinclude01: " ",
        locationcategoryinclude02: " ",
        locationcategoryinclude03: " ",
        locationflagexclude01: " ",
        locationflagexclude02: " ",
        locationflagexclude03: " ",
        locationflaginclude01: " ",
        locationflaginclude02: " ",
        locationflaginclude03: " ",
        locationhandlingexclude01: " ",
        locationhandlingexclude02: " ",
        locationhandlingexclude03: " ",
        locationhandlinginclude01: " ",
        locationhandlinginclude02: " ",
        locationhandlinginclude03: " ",
        locationstaterestriction01: "0",
        locationstaterestriction02: "0",
        locationstaterestriction03: "0",
        locationtypeexclude01: " ",
        locationtypeexclude02: " ",
        locationtypeexclude03: " ",
        locationtypeexclude04: "PICKTO",
        locationtypeexclude05: "STAGED",
        locationtyperestriction01: " ",
        locationtyperestriction02: " ",
        locationtyperestriction03: " ",
        locsearchtype: "1",
        loctype: " ",
        numberofdaysoffset: 0,
        ordertype: " ",
        patype: "",
        patypename: " ",
        receipttypeexclude01: " ",
        receipttypeexclude02: " ",
        receipttypeexclude03: " ",
        receipttypeinclude01: " ",
        receipttypeinclude02: " ",
        receipttypeinclude03: " ",
        singleputawayformultipallets: "N",
        skuabcexclude01: " ",
        skuabcexclude02: " ",
        skuabcexclude03: " ",
        skuabcinclude01: " ",
        skuabcinclude02: " ",
        skuabcinclude03: " ",
        skubusr01exclude01: " ",
        skubusr01exclude02: " ",
        skubusr01exclude03: " ",
        skubusr01include01: " ",
        skubusr01include02: " ",
        skubusr01include03: " ",
        skubusr02exclude01: " ",
        skubusr02exclude02: " ",
        skubusr02exclude03: " ",
        skubusr02include01: " ",
        skubusr02include02: " ",
        skubusr02include03: " ",
        skubusr03exclude01: " ",
        skubusr03exclude02: " ",
        skubusr03exclude03: " ",
        skubusr03include01: " ",
        skubusr03include02: " ",
        skubusr03include03: " ",
        skubusr04exclude01: " ",
        skubusr04exclude02: " ",
        skubusr04exclude03: " ",
        skubusr04include01: " ",
        skubusr04include02: " ",
        skubusr04include03: " ",
        skubusr05exclude01: " ",
        skubusr05exclude02: " ",
        skubusr05exclude03: " ",
        skubusr05include01: " ",
        skubusr05include02: " ",
        skubusr05include03: " ",
        skubusr06exclude01: " ",
        skubusr06exclude02: " ",
        skubusr06exclude03: " ",
        skubusr06include01: " ",
        skubusr06include02: " ",
        skubusr06include03: " ",
        skubusr07exclude01: " ",
        skubusr07exclude02: " ",
        skubusr07exclude03: " ",
        skubusr07include01: " ",
        skubusr07include02: " ",
        skubusr07include03: " ",
        skubusr08exclude01: " ",
        skubusr08exclude02: " ",
        skubusr08exclude03: " ",
        skubusr08include01: " ",
        skubusr08include02: " ",
        skubusr08include03: " ",
        skubusr09exclude01: " ",
        skubusr09exclude02: " ",
        skubusr09exclude03: " ",
        skubusr09include01: " ",
        skubusr09include02: " ",
        skubusr09include03: " ",
        skubusr10exclude01: " ",
        skubusr10exclude02: " ",
        skubusr10exclude03: " ",
        skubusr10include01: " ",
        skubusr10include02: " ",
        skubusr10include03: " ",
        skufreightclassexclude01: " ",
        skufreightclassexclude02: " ",
        skufreightclassexclude03: " ",
        skufreightclassinclude01: " ",
        skufreightclassinclude02: " ",
        skufreightclassinclude03: " ",
        itemputawayclassinclude01: " ",
        itemputawayclassinclude02: " ",
        itemputawayclassinclude03: " ",
        itemputawayclassexclude01: " ",
        itemputawayclassexclude02: " ",
        itemputawayclassexclude03: " ",
        skususr01exclude01: " ",
        skususr01exclude02: " ",
        skususr01exclude03: " ",
        skususr01include01: " ",
        skususr01include02: " ",
        skususr01include03: " ",
        skususr02exclude01: " ",
        skususr02exclude02: " ",
        skususr02exclude03: " ",
        skususr02include01: " ",
        skususr02include02: " ",
        skususr02include03: " ",
        skususr03exclude01: " ",
        skususr03exclude02: " ",
        skususr03exclude03: " ",
        skususr03include01: " ",
        skususr03include02: " ",
        skususr03include03: " ",
        skususr04exclude01: " ",
        skususr04exclude02: " ",
        skususr04exclude03: " ",
        skususr04include01: " ",
        skususr04include02: " ",
        skususr04include03: " ",
        skususr05exclude01: " ",
        skususr05exclude02: " ",
        skususr05exclude03: " ",
        skususr05include01: " ",
        skususr05include02: " ",
        skususr05include03: " ",
        skususr06exclude01: " ",
        skususr06exclude02: " ",
        skususr06exclude03: " ",
        skususr06include01: " ",
        skususr06include02: " ",
        skususr06include03: " ",
        skususr07exclude01: " ",
        skususr07exclude02: " ",
        skususr07exclude03: " ",
        skususr07include01: " ",
        skususr07include02: " ",
        skususr07include03: " ",
        skususr08exclude01: " ",
        skususr08exclude02: " ",
        skususr08exclude03: " ",
        skususr08include01: " ",
        skususr08include02: " ",
        skususr08include03: " ",
        skususr09exclude01: " ",
        skususr09exclude02: " ",
        skususr09exclude03: " ",
        skususr09include01: " ",
        skususr09include02: " ",
        skususr09include03: " ",
        skususr10exclude01: " ",
        skususr10exclude02: " ",
        skususr10exclude03: " ",
        skususr10include01: " ",
        skususr10include02: " ",
        skususr10include03: " ",
        toloc: "",
        zone: " ",
        zonename: " ",
        putawaystrategykey: this.argument.putawaystrategykey
      };
      try {
        let res = await this.$api.post(`/queryputawaydetailmaxstepnumber`, this.detailData);
        
          this.detailData.stepnumber = (this.detailData.stepnumber - 0) + (res.data.token - 0);
          this.detailsFlag = true;
          this.detailNav = '2';
        
      } catch (e) {
        this.$message.error(e);
      }
    },
    //导航值
    setMentActive (key) {
      this.detailNav = key;
    },

    async enterDetails (data) {
      try {
        let res = await this.$api.get(`/querybyputawaystrategydetail12/${data.serialkey}`);
        
          this.detailData = res.bean;
          this.detailNav = '2';
      } catch (e) {
        this.$message.error(e);
      }

    }

  },
  mounted () {
    this.newFlag = this.$store.state.newFlag;
    if (Object.keys(this.$store.state.skip).length !== 0) {
      let data = this.$store.state.skip;
      this.argument = data.routeData;
      this.detailData = data.detailList;
      this.detailNav = data.detailListNav;
      this.detailsFlag = data.detailListFlag
    } else if (this.newFlag) {
      this.newFlag = true;
      this.detailData = {
        stepnumber: '10',
        putawaystrategylinenumber: "1",
        allowfullcases: "Y",
        allowfullpallets: "Y",
        allowpieces: "Y",
        areakey: " ",
        areatypeexclude01: " ",
        areatypeexclude02: " ",
        areatypeexclude03: " ",
        checkequipmentprofilekey: "N",
        checkrestrictions: "Y",
        dimensionrestriction01: "0",
        dimensionrestriction02: "0",
        dimensionrestriction03: "0",
        dimensionrestriction04: "0",
        dimensionrestriction05: "0",
        dimensionrestriction06: "0",
        dispositiontypeexclude01: " ",
        dispositiontypeexclude02: " ",
        dispositiontypeexclude03: " ",
        dispositiontypeinclude01: " ",
        dispositiontypeinclude02: " ",
        dispositiontypeinclude03: " ",
        fitfullreceipt: "N",
        fromloc: "",
        locabcexclude01: " ",
        locabcexclude02: " ",
        locabcexclude03: " ",
        locabcinclude01: " ",
        locabcinclude02: " ",
        locabcinclude03: " ",
        locationcategoryexclude01: " ",
        locationcategoryexclude02: " ",
        locationcategoryexclude03: " ",
        locationcategoryinclude01: " ",
        locationcategoryinclude02: " ",
        locationcategoryinclude03: " ",
        locationflagexclude01: " ",
        locationflagexclude02: " ",
        locationflagexclude03: " ",
        locationflaginclude01: " ",
        locationflaginclude02: " ",
        locationflaginclude03: " ",
        locationhandlingexclude01: " ",
        locationhandlingexclude02: " ",
        locationhandlingexclude03: " ",
        locationhandlinginclude01: " ",
        locationhandlinginclude02: " ",
        locationhandlinginclude03: " ",
        locationstaterestriction01: "0",
        locationstaterestriction02: "0",
        locationstaterestriction03: "0",
        locationtypeexclude01: " ",
        locationtypeexclude02: " ",
        locationtypeexclude03: " ",
        locationtypeexclude04: "PICKTO",
        locationtypeexclude05: "STAGED",
        locationtyperestriction01: " ",
        locationtyperestriction02: " ",
        locationtyperestriction03: " ",
        locsearchtype: "1",
        loctype: " ",
        numberofdaysoffset: 0,
        ordertype: " ",
        patype: "",
        patypename: " ",
        receipttypeexclude01: " ",
        receipttypeexclude02: " ",
        receipttypeexclude03: " ",
        receipttypeinclude01: " ",
        receipttypeinclude02: " ",
        receipttypeinclude03: " ",
        singleputawayformultipallets: "N",
        skuabcexclude01: " ",
        skuabcexclude02: " ",
        skuabcexclude03: " ",
        skuabcinclude01: " ",
        skuabcinclude02: " ",
        skuabcinclude03: " ",
        skubusr01exclude01: " ",
        skubusr01exclude02: " ",
        skubusr01exclude03: " ",
        skubusr01include01: " ",
        skubusr01include02: " ",
        skubusr01include03: " ",
        skubusr02exclude01: " ",
        skubusr02exclude02: " ",
        skubusr02exclude03: " ",
        skubusr02include01: " ",
        skubusr02include02: " ",
        skubusr02include03: " ",
        skubusr03exclude01: " ",
        skubusr03exclude02: " ",
        skubusr03exclude03: " ",
        skubusr03include01: " ",
        skubusr03include02: " ",
        skubusr03include03: " ",
        skubusr04exclude01: " ",
        skubusr04exclude02: " ",
        skubusr04exclude03: " ",
        skubusr04include01: " ",
        skubusr04include02: " ",
        skubusr04include03: " ",
        skubusr05exclude01: " ",
        skubusr05exclude02: " ",
        skubusr05exclude03: " ",
        skubusr05include01: " ",
        skubusr05include02: " ",
        skubusr05include03: " ",
        skubusr06exclude01: " ",
        skubusr06exclude02: " ",
        skubusr06exclude03: " ",
        skubusr06include01: " ",
        skubusr06include02: " ",
        skubusr06include03: " ",
        skubusr07exclude01: " ",
        skubusr07exclude02: " ",
        skubusr07exclude03: " ",
        skubusr07include01: " ",
        skubusr07include02: " ",
        skubusr07include03: " ",
        skubusr08exclude01: " ",
        skubusr08exclude02: " ",
        skubusr08exclude03: " ",
        skubusr08include01: " ",
        skubusr08include02: " ",
        skubusr08include03: " ",
        skubusr09exclude01: " ",
        skubusr09exclude02: " ",
        skubusr09exclude03: " ",
        skubusr09include01: " ",
        skubusr09include02: " ",
        skubusr09include03: " ",
        skubusr10exclude01: " ",
        skubusr10exclude02: " ",
        skubusr10exclude03: " ",
        skubusr10include01: " ",
        skubusr10include02: " ",
        skubusr10include03: " ",
        skufreightclassexclude01: " ",
        skufreightclassexclude02: " ",
        skufreightclassexclude03: " ",
        skufreightclassinclude01: " ",
        skufreightclassinclude02: " ",
        skufreightclassinclude03: " ",
        skususr01exclude01: " ",
        skususr01exclude02: " ",
        skususr01exclude03: " ",
        skususr01include01: " ",
        skususr01include02: " ",
        skususr01include03: " ",
        skususr02exclude01: " ",
        skususr02exclude02: " ",
        skususr02exclude03: " ",
        skususr02include01: " ",
        skususr02include02: " ",
        skususr02include03: " ",
        skususr03exclude01: " ",
        skususr03exclude02: " ",
        skususr03exclude03: " ",
        skususr03include01: " ",
        skususr03include02: " ",
        skususr03include03: " ",
        skususr04exclude01: " ",
        skususr04exclude02: " ",
        skususr04exclude03: " ",
        skususr04include01: " ",
        skususr04include02: " ",
        skususr04include03: " ",
        skususr05exclude01: " ",
        skususr05exclude02: " ",
        skususr05exclude03: " ",
        skususr05include01: " ",
        skususr05include02: " ",
        skususr05include03: " ",
        skususr06exclude01: " ",
        skususr06exclude02: " ",
        skususr06exclude03: " ",
        skususr06include01: " ",
        skususr06include02: " ",
        skususr06include03: " ",
        skususr07exclude01: " ",
        skususr07exclude02: " ",
        skususr07exclude03: " ",
        skususr07include01: " ",
        skususr07include02: " ",
        skususr07include03: " ",
        skususr08exclude01: " ",
        skususr08exclude02: " ",
        skususr08exclude03: " ",
        skususr08include01: " ",
        skususr08include02: " ",
        skususr08include03: " ",
        skususr09exclude01: " ",
        skususr09exclude02: " ",
        skususr09exclude03: " ",
        skususr09include01: " ",
        skususr09include02: " ",
        skususr09include03: " ",
        skususr10exclude01: " ",
        skususr10exclude02: " ",
        skususr10exclude03: " ",
        skususr10include01: " ",
        skususr10include02: " ",
        skususr10include03: " ",
        toloc: "",
        zone: " ",
        zonename: " ",
      };
      this.detailNav = "2";
    } else {
      this.argument = this.$store.state.routeData;
    }
  },
  components: {
    "v-tableTitle": tableTitle,
    "v-navMenu": navMenu,
  },

}
</script>

<style>
</style>
